package com.siyu.basedata.iothlpoint.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.basedata.iothlpoint.domain.IotHLPoint;
import com.siyu.basedata.iothlpoint.service.IIotHLPointService;

/**
 * 水文测站基本信息Controller
 *
 * @author hrhy
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/basedata/iothlpoint")
public class IotHLPointController extends BaseController {
    @Autowired
    private IIotHLPointService iotHLPointService;

    /**
     * 查询水文测站基本信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(IotHLPoint iotHLPoint) {
        startPage();
        List<IotHLPoint> list = iotHLPointService.selectIotHLPointList(iotHLPoint);
        return getDataTable(list);
    }

    /**
     * 导出水文测站基本信息列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, IotHLPoint iotHLPoint) {
        List<IotHLPoint> list = iotHLPointService.selectIotHLPointList(iotHLPoint);
        ExcelUtil<IotHLPoint> util = new ExcelUtil<IotHLPoint>(IotHLPoint.class);
        util.exportExcel(response, list, "水文测站基本信息数据");
    }

    /**
     * 获取水文测站基本信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(iotHLPointService.selectIotHLPointById(id));
    }

    /**
     * 新增水文测站基本信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody IotHLPoint iotHLPoint) {
        return toAjax(iotHLPointService.insertIotHLPoint(iotHLPoint));
    }

    /**
     * 修改水文测站基本信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody IotHLPoint iotHLPoint) {
        return toAjax(iotHLPointService.updateIotHLPoint(iotHLPoint));
    }

    /**
     * 删除水文测站基本信息
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(iotHLPointService.deleteIotHLPointByIds(ids));
    }
}
